home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / fsp-2.7 / fsp-2 / fsp / clients / fcdcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-21  |  2.0 KB  |  80 lines

  1.     /*********************************************************************\
  2.     *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  3.     *                                                                     *
  4.     *  You may copy or modify this file in any manner you wish, provided  *
  5.     *  that this notice is always included, and that you hold the author  *
  6.     *  harmless for any loss or damage resulting from the installation or *
  7.     *  use of this software.                                              *
  8.     \*********************************************************************/
  9.  
  10. #include "tweak.h"
  11. #include "client_def.h"
  12. #include "c_extern.h"
  13. #include "bsd_extern.h"
  14.  
  15. extern char *env_dir;
  16.  
  17. #define Y_or_N(y) ((flags & (y)) ?  "Y" : "N")
  18. #define Machine(y) ((flags & (y)) ? "you" : "other")
  19.  
  20. static int print_pro PROTO1(char *, p)
  21. {
  22.   UBUF *ub;
  23.   char flags;
  24.   unsigned len, len1;
  25.   char *pro1, *pro2;
  26.   
  27.   ub = client_interact(CC_GET_PRO,0L, strlen(p), (unsigned char *)p+1, 0,
  28.                (unsigned char *)NULLP);
  29.   len = BB_READ2(ub->bb_len); len1 = BB_READ4(ub->bb_pos);
  30.   pro1 = ub->buf; pro2 = ub->buf+len;
  31.   
  32.   if(ub->cmd == CC_ERR) {
  33.     fprintf(stderr, "ERR: %s\n",ub->buf);
  34.     return(0);
  35.   } else {
  36.     fprintf(stderr, "directory mode: ");
  37.     if(len1) {
  38.       flags = *pro2;
  39.       fprintf(stderr,
  40.           "(owner: %s)(del: %s)(create: %s)(mkdir: %s)(private: %s)\n",
  41.           Machine(DIR_OWNER), Y_or_N(DIR_DEL), Y_or_N(DIR_ADD),
  42.           Y_or_N(DIR_MKDIR), Y_or_N(DIR_PRIV));
  43.     }
  44.     fprintf(stderr, "%s", pro1);
  45.     fprintf(stderr, "\n");
  46.     return(1);
  47.   }
  48. }
  49.  
  50. int main PROTO3(int, argc, char **, argv, char **, envp)
  51. {
  52.   char *np;
  53.   char **av, *av2[2];
  54.   
  55.   env_client();
  56.   if(argc == 1) {
  57.     print_pro("/");
  58.     puts("/");
  59.   } else {
  60.     if(!(av = glob(argv[1]))) {
  61.       av = av2;
  62.       av2[0] = *argv;
  63.       av2[1] = 0;
  64.     }
  65.     np = util_abs_path(*av);
  66.     if(print_pro(np))puts(np);
  67.     else {
  68. #ifdef VMS
  69.       puts(env_dir);
  70.       client_done();
  71.       exit(3);
  72. #else
  73.       puts(env_dir);
  74. #endif /* VMS */
  75.     }
  76.   }
  77.   client_done();
  78.   exit(0);
  79. }
  80.